package org.learn;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author Rollin
 * @date 2019-06-13 09:25
 */
@Component
public class FederationListener {

    @RabbitListener(queues = "fed.queue_1")
    private void processGroupMessagePullRequest(Channel channel,
                                                @Payload byte[] payload,
                                                @Headers Map<String, Object> headers,
                                                @Header(AmqpHeaders.DELIVERY_TAG) Long deliveryTag) throws Exception {
        System.err.println(new String(payload,"UTF-8"));
        channel.basicAck(deliveryTag,false);
    }
}
